package com.gzedu.module.faced.role.impl;

import java.util.Date;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import com.gzedu.module.faced.role.RoleFacade;
import com.gzedu.module.modle.role.Role;
import com.gzedu.module.service.role.IRoleService;
import com.gzedu.module.utils.IdGen;

@Service
public class RoleFacadeImpl implements RoleFacade{
	
	@Resource
	private IRoleService roleService;

	public Role getRoleById(String roleId) {
		// TODO Auto-generated method stub
		return roleService.getById(roleId);
	}

	public boolean save(Role role) {
		// TODO Auto-generated method stub
		int res = 0;
		if(StringUtils.isEmpty(role.getId())){
			String id = IdGen.creatUUID();
			role.setId(id);
			//role.setCreate_date(new Date());
			res = roleService.insert(role);
		}else{
			res = update(role);
		}
		
		if(res == 1){
			return true;
		}else{
			return false;
		}
		
	}

	public int update(Role role) {
		// TODO Auto-generated method stub
		//role.setModifty_date(new Date());
		return roleService.updateById(role);
	}
	
}
